/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.lejos.example;

import java.util.Scanner;

/**
 *
 * @author zach
 */
public class RouteHandler {
    private Scanner man;
    public RouteHandler(String in) {
        man=new Scanner(in);
    }
    public int getNextdirection(){
        if(man.hasNext()){
            String[] point =man.nextLine().split(" ");
            String[] one =point[0].split(",");
            String[] two =point[1].split(",");
            //backwards
            if(Integer.parseInt(one[0])>Integer.parseInt(two[0]))
                return 0;
            //forwards
            else if(Integer.parseInt(one[0])<Integer.parseInt(two[0]))
                return 1;
            //right
            else if(Integer.parseInt(one[1])>Integer.parseInt(two[1]))
                return 2;
            //left
            else if(Integer.parseInt(one[1])<Integer.parseInt(two[1]))
                return 3;
            //error
            else return -2;

        }
        return-1;
    }
}
